package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.entity.Setmeal;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    //套餐分页查询

    Page<SetmealVO> listByCondition(Setmeal setmeal);

    void deleteByIds(List<Long> ids);

    void update(Setmeal setmeal);

    Setmeal selectById(Long id);

    List<Setmeal> selectByName(Setmeal setmeal);

    void insert(Setmeal setmeal);
    @Select("select count(*) from setmeal where category_id = #{id}")
    Integer countByCategoryId(Long id);

    //用户端

    List<Setmeal> list(Setmeal setmeal);
    /**
     * 根据套餐id查询菜品选项
     * @param setmealId
     * @return
     */
    @Select("select sd.name, sd.copies, d.image, d.description " +
            "from setmeal_dish sd left join dish d on sd.dish_id = d.id " +
            "where sd.setmeal_id = #{setmealId}")
    List<DishItemVO> getDishItemBySetmealId(Long setmealId);


}
